<%--
  Created by IntelliJ IDEA.
  User: 19416
  Date: 2022-10-05
  Time: 15:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="JS/jquery-2.1.1.min.js">

    </script>
</head>
<body>

<form action="PowerBatteryUpdateServlet" method="get">
    <p>
        id:<input type="text" name="id" value="${requestScope.powerbattery.id}">
    </p>
    <p>
        车辆类型：<input type="text" name="carName" value="${requestScope.powerbattery.carName}" id="carName">
    </p>
    <p>
        所属城市： <input type="text" name="cityName" value="${requestScope.powerbattery.cityName}" id="cityName">
    </p>
    <p>
        使用单位： <input type="text" name="userName" value="${requestScope.powerbattery.userName}" id="userName">
    </p>
    <p>
        压差报警值<input type="text" name="pressureValue" value="${requestScope.powerbattery.pressureValue}" id="pressureValue">
    </p>
    <p>
        时间： <input type="text" name="time" value="${requestScope.powerbattery.time}" id="time">
    </p>
    <p>
        <input type="submit" value="修改" id="btn">
    </p>
</form>
<script>
    $("#btn").click(function (){
        var carName = $("#carName").val();
        var cityName = $("#cityName").val();
        var userName = $("#userName").val();
        var pressureValue = $("#pressureValue").val();
        var time = $("#time").val();
        var isDate = /^\d{4}[-]\d{2}[-]\d{2}$/;
        var reg = /([\u4E00-\u9FA5]|[A-Za-z])+/;//只要包含中文或者字母就提示
        if (carName.length == 0 || cityName.length == 0 || userName.length == 0 || pressureValue.length == 0|| carName.length == 0){
            alert("请填写完整信息")
            return false;
        }else if (!isDate.test(time)){
            alert("时间格式必须是:yy-MM-dd格式")
            return false;
        }else if (reg.test(pressureValue)){
            alert("压差报警值必须是整型")
            return false;
        }else {
            alert("修改成功")

        }
    })
</script>
</body>
</html>
